package cn.home.DYX.service.impl;

import java.util.List;

import cn.home.DYX.mapper.HomeDoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.home.DYX.mapper.HomeTeamMapper;
import cn.home.DYX.domain.HomeTeam;
import cn.home.DYX.service.IHomeTeamService;

/**
 * 团队管理Service业务层处理
 * 
 * @author 丁宇翔
 * @date 2025-04-09
 */
@Service
public class HomeTeamServiceImpl implements IHomeTeamService 
{
    @Autowired
    private HomeTeamMapper homeTeamMapper;
    //医生信息
    @Autowired
    private HomeDoctorMapper homeDoctorMapper;


    /**
     * 查询团队管理
     * 
     * @param id 团队管理主键
     * @return 团队管理
     */
    @Override
    public HomeTeam selectHomeTeamById(Long id)
    {
        return homeTeamMapper.selectHomeTeamById(id);
    }

    /**
     * 查询团队管理列表
     * 
     * @param homeTeam 团队管理
     * @return 团队管理
     */
    @Override
    public List<HomeTeam> selectHomeTeamList(HomeTeam homeTeam)
    {
        return homeTeamMapper.selectHomeTeamList(homeTeam);
    }

    /**
     * 新增团队管理
     * 
     * @param homeTeam 团队管理
     * @return 结果
     */
    @Override
    public int insertHomeTeam(HomeTeam homeTeam)
    {
        //添加后团队的id
        int i = homeTeamMapper.insertHomeTeam(homeTeam);
        System.out.println(i);
        return i;
    }

    /**
     * 修改团队管理
     * 
     * @param homeTeam 团队管理
     * @return 结果
     */
    @Override
    public int updateHomeTeam(HomeTeam homeTeam)
    {
        return homeTeamMapper.updateHomeTeam(homeTeam);
    }

    /**
     * 批量删除团队管理
     * 
     * @param ids 需要删除的团队管理主键
     * @return 结果
     */
    @Override
    public int deleteHomeTeamByIds(Long[] ids)
    {
        return homeTeamMapper.deleteHomeTeamByIds(ids);
    }

    /**
     * 删除团队管理信息
     * 
     * @param id 团队管理主键
     * @return 结果
     */
    @Override
    public int deleteHomeTeamById(Long id)
    {
        return homeTeamMapper.deleteHomeTeamById(id);
    }

    //根据团队id查询团队信息和医生信息以及服务包信息
    @Override
    public HomeTeam selectHomeDoctorByTeamId(Long teamId) {
        //查看团队信息
        HomeTeam homeTeam = homeTeamMapper.selectHomeTeamById(teamId);
        //查看医生信息
        homeTeam.setHomeDoctorList(homeDoctorMapper.selectHomeDoctorByTeamId(teamId));
        //查看服务包信息
        //
        return homeTeam;
    }

    @Override
    public int addLabel(int teamId, int ida, int idb, int idc) {
        //根据团队id添加标签
        int i = homeTeamMapper.addLabel(teamId, ida, idb, idc);
        return i;
    }

    @Override
    public int addMember(Long teamId, Long memberId) {
        //根据团队id添加成员
        int i = homeTeamMapper.addMember(teamId, memberId);
        return i;
    }

    @Override
    public int addServicePackage(Long teamId, Long serviceid) {
        int i = homeTeamMapper.addServicePackage(teamId, serviceid);
        return i;
    }


}
